#include <iostream>
#include <vector>
#include <algorithm>
#define MAXN 100
using namespace std;
using Work = pair<int, int>;
int N;
Work works[MAXN];
void solve();

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> works[i].first;
    for (int i = 0; i < N; i++) cin >> works[i].second;
    solve();
    return 0;
}

bool cmp(const Work &w1, const Work &w2) {
    if (w1.second < w2.second) return true;
    return w1.first <= w2.first;
}

// 最早结束优先
void solve() {
    sort(works, works + N, cmp);
    int last_time = works[0].second, n = 1;
    for (int i = 1; i < N; i++) {
        if (works[i].first < last_time) continue;
        n++; last_time = works[i].second;
    } 
    cout << n << endl;
}